import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:niuren_demo/configs/App_style_config.dart';
import 'package:niuren_demo/model/TeamPage_model.dart';
import 'package:niuren_demo/view/text/text_style.dart';

class TeamItem extends StatelessWidget {
  final TemaNembers dataMode;

  const TeamItem({Key key, this.dataMode}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
      margin: EdgeInsets.only(bottom: 6),
      child: Column(
        children: [
          Row(
            children: [
              Container(
                width: 40,
                height: 40,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(
                    Radius.circular(2),
                  ),
                  image: DecorationImage(
                    image: NetworkImage(
                      dataMode?.headImage ?? "",
                    ),
                    fit: BoxFit.cover,
                  ),
                ),
              ),
              SizedBox(
                width: 6,
              ),
              Expanded(
                child: Column(
                  children: [
                    Row(
                      children: [
                        Expanded(child: Row(
                          children: [
                            Text_style(
                              data: dataMode?.userName ?? "",
                              color: Colors.black,
                              fontSize: 14,
                            ),
                            SizedBox(width: 4),
                            Visibility(
                              visible: dataMode.fauild == 1,
                              child: Icon(
                                Icons.error_outline,
                                size: 16,
                                color: Colors.red,
                              ),
                            ),
                          ],
                        ),),
                        Row(
                          children: [
                            Container(
                              padding: EdgeInsets.symmetric(horizontal: 4),
                              child: Text(
                                dataMode.bandingState == 0 ? "未绑定" : "已绑定",
                                style: TextStyle(
                                    color: AppStyleConfig.themColor, fontSize: 12),
                              ),
                            ),
                            SizedBox(
                              width: 4,
                            ),
                          ],
                        ),
                        Row(
                          children: [
                            Container(
                              padding: EdgeInsets.symmetric(horizontal: 4),
                              child: Text(
                                dataMode.floweStat == 0 ? "未跟单" : "已跟单",
                                style: TextStyle(
                                    color: AppStyleConfig.themColor, fontSize: 12),
                              ),
                            ),
                          ],
                        ),
                      ],
                    ),
                    SizedBox(height: 6,),
                    Row(
                      children: [
                        Expanded(child: Text(
                          dataMode?.time??"",
                          style: TextStyle(
                            color: Colors.grey,
                            fontSize: 10,
                          ),
                        ),),
                        Container(
                          color: AppStyleConfig.themColor,
                          padding: EdgeInsets.symmetric(horizontal: 4),
                          child: Text(
                            dataMode.relation == 0 ? "直接" : "间接",
                            style: TextStyle(
                                color: Colors.white, fontSize: 12),
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
            ],
          ),
          Container(
            padding: EdgeInsets.only(top: 18),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                buildTeamItemBottom(title: "收益分成", amount: dataMode?.earnings??"0.00",),
                buildTeamItemBottom(title: "今日跟单", amount: dataMode?.todyFlowe??"0.00",),
                buildTeamItemBottom(title: "累计跟单", amount: dataMode?.floweTotal??"0.00",),
              ],
            ),
          ),
        ],
      ),
    );
  }
  Widget buildTeamItemBottom({@required String title, String amount}) {
    return Column(
      children: [
        Text(
          amount ?? "0.00",
          style: TextStyle(color: Colors.greenAccent, fontSize: 16, fontWeight: FontWeight.bold),
        ),
        Text(
          title,
          style: TextStyle(color: Colors.grey, fontSize: 12),
        ),
      ],
    );
  }
}
